home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / join.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  8.9 KB  |  373 lines

  1. #include "bbs.h"
  2. #include <dos/dos.h>
  3. #include <dos/dosextens.h>
  4. ULONG ConfBaseLine;
  5. extern int NotRelative;
  6. #define USERDATA 0
  7. #define CONFTOTAL 1
  8. #define CONF      2
  9. #define Tell(x)  Seek(x,0L,OFFSET_CURRENT)
  10. extern struct DiskObject *ConfObj;
  11. extern UBYTE NewSinceFlag;
  12. extern struct List *ConfDBList;
  13. struct MyConfBase
  14. {
  15.   struct MinNode l;
  16.   struct ConfBase CB;
  17. };
  18. void GetConfName(char *n,char *l,int Conf)
  19. {
  20.   char **oldtooltypes;
  21.   char *s;
  22.   char temp[100];
  23.    
  24.   oldtooltypes=ConfObj->do_ToolTypes;
  25.   sprintf(temp,"NAME.%d",Conf+1);
  26.  
  27.   s=FindToolType(oldtooltypes,temp);
  28.   if(s!=NULL) strcpy(n,s);
  29.   sprintf(temp,"LOCATION.%d",Conf+1);
  30.   s=FindToolType(oldtooltypes,temp);
  31.  
  32.   if(s!=NULL) { strcpy(l,s);  sprintf(MsgBase_Location,"%sMsgBase/",l); 
  33.                               sprintf(Upload_Location,"%sUpload/",l);
  34.               }
  35. }
  36.  
  37. int IsTempConf(struct User *p,int Conf)
  38. {
  39.    char temp[100];
  40.    char temp1[30];
  41.    sprintf(temp,"%sACCESS/AREA.%s",Cmds->BBSLoc,p->Conference_Access);
  42.    sprintf(temp1,"CONF.%d",Conf+1);
  43.    if(IsFromIcon(temp,temp1)) return(1); else return(0);
  44. }
  45. int IsValidConf(int Conf)
  46. {
  47.    if(GetAreaBit(Conf)) return(1); else return(0);
  48. }
  49.  
  50.  
  51. void MasterLoadPointers(void)
  52. {
  53.    BPTR bi;
  54.    struct ConfBase t;
  55.    struct MyConfBase *it;
  56.    struct MyConfBase *tt;
  57.    char temp[100];
  58.    register int i;
  59.    if(User.Slot_Number<=0) {
  60.        return;
  61.      }
  62.    it=(struct MyConfBase *)(ConfDBList->lh_Head);
  63.    i=0;
  64.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  65.    {
  66.      GetConfName(temp,Conference_Location,i);
  67.      i++;
  68.      sprintf(temp,"%sConf.DB",Conference_Location);
  69.      bi=Open(temp,MODE_OLDFILE);
  70.      if(bi==NULL)
  71.      {
  72.        CallersLog("\tError can't open >:"); CallersLog(temp); CallersLog("\n");
  73.        return;
  74.      }
  75.     
  76.      if(Seek(bi,(ULONG)(User.Slot_Number-1)*(ULONG)(sizeof(struct ConfBase)),OFFSET_BEGINNING)==-1)
  77.      {
  78.        CallersLog("\tError Reading MsgBase Pointer\n"); Close(bi); return;
  79.      }
  80.    
  81.      FRead(bi,(APTR)&t,(ULONG)sizeof(struct ConfBase),1L);
  82.      CopyMem(&t,(APTR)&(it->CB),sizeof(struct ConfBase));
  83.      
  84.    Close(bi);
  85.      it=tt;
  86.   }
  87. }
  88. void MasterSavePointers(void)
  89. {
  90.    BPTR bi;
  91.    struct ConfBase t;
  92.    struct MyConfBase *it;
  93.    struct MyConfBase *tt;
  94.    char temp[100];
  95.    register int i;
  96.  if(User.Slot_Number<=0) {
  97.        return;
  98.      }
  99.    it=(struct MyConfBase *)(ConfDBList->lh_Head);
  100.    i=0;
  101.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  102.    {
  103.      GetConfName(temp,Conference_Location,i);
  104.      i++;
  105.      sprintf(temp,"%sConf.DB",Conference_Location);
  106.      bi=Open(temp,MODE_OLDFILE);
  107.      if(bi==NULL)
  108.      {
  109.        CallersLog("\tError can't open >:"); CallersLog(temp); CallersLog("\n");
  110.        return;
  111.      }
  112.       
  113.      if(Seek(bi,(ULONG)(User.Slot_Number-1)*(ULONG)(sizeof(struct ConfBase)),OFFSET_BEGINNING)==-1)
  114.      {
  115.        CallersLog("\tError Reading MsgBase Pointer\n"); Close(bi); return;
  116.      }
  117.      CopyMem((APTR)&(it->CB),(APTR)&t,sizeof(struct ConfBase));
  118.      Write(bi,(APTR)&t,(ULONG)sizeof(struct ConfBase));
  119.      
  120.    Close(bi);
  121.      it=tt;
  122.   }
  123. }
  124. /***** Send Actual Conf + 1 to this routine *****/
  125. void SaveMsgPointers(int CN)
  126. {
  127.    struct MyConfBase *it;
  128.    struct MyConfBase *tt;
  129.    register int i;
  130.    if(User.Slot_Number<=0) {
  131.        Last_Msg_Read_Conf=0;
  132.        Last_New_Read_Conf=0;
  133.        return;
  134.    }
  135.    it=(struct MyConfBase *)(ConfDBList->lh_Head);
  136.    i=0;
  137.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  138.    {
  139.       if(CN-1==i)
  140.       {
  141. if(GET_BIT(ACS_CONFERENCE_ACCOUNTING))
  142.         {
  143.          it->CB.Bytes_Download= User.Bytes_Download;
  144.          it->CB.Bytes_Upload= User.Bytes_Upload;      
  145.          //it->CB.Daily_Bytes_Limit= User.Daily_Bytes_Limit;
  146.          //it->CB.Daily_Bytes_Dld= User.Daily_Bytes_Dld;   
  147.          it->CB.Upload= User.Uploads;           
  148.          it->CB.Downloads= User.Downloads;         
  149.          it->CB.RatioType= User.Sec_Board;         
  150.          it->CB.Ratio= User.Sec_Library;       
  151.          it->CB.Messages_Posted= User.Messages_Posted;   
  152.  
  153.         }        if(NewSinceFlag)it->CB.NewSinceDate=time(NULL);
  154.         it->CB.ConfYM=Last_Msg_Read_Conf;
  155.         it->CB.ConfRead=Last_New_Read_Conf;
  156.         return;
  157.       }
  158.       i++;
  159.       it=tt;
  160.    }
  161.  
  162. }
  163. /***** Send Actual Conf + 1 to this routine *****/
  164. void LoadMsgPointers(int CN)
  165. {
  166.    struct MyConfBase *it;
  167.    struct MyConfBase *tt;
  168.    register int i;
  169.    if(User.Slot_Number<=0) {
  170.        Last_Msg_Read_Conf=0;
  171.        Last_New_Read_Conf=0;
  172.        return;
  173.    }
  174.    it=(struct MyConfBase *)(ConfDBList->lh_Head);
  175.    i=0;
  176.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  177.    {
  178.       if(CN-1==i)
  179.       {
  180.         if(GET_BIT(ACS_CONFERENCE_ACCOUNTING))
  181.         {
  182.           User.Bytes_Download=    it->CB.Bytes_Download;
  183.           User.Bytes_Upload=      it->CB.Bytes_Upload;
  184.           //User.Daily_Bytes_Limit= it->CB.Daily_Bytes_Limit;
  185.           //User.Daily_Bytes_Dld=   it->CB.Daily_Bytes_Dld;
  186.           User.Uploads=           it->CB.Upload;
  187.           User.Downloads=         it->CB.Downloads;
  188.           User.Sec_Board=         it->CB.RatioType;
  189.           User.Sec_Library=       it->CB.Ratio;
  190.           User.Messages_Posted=   it->CB.Messages_Posted;
  191.  
  192.         }
  193.         if(NewSinceFlag)it->CB.NewSinceDate=time(NULL);
  194.         Last_Msg_Read_Conf=it->CB.ConfYM;
  195.         Last_New_Read_Conf=it->CB.ConfRead;
  196.         return;
  197.       }
  198.       i++;
  199.       it=tt;
  200.    }
  201.  
  202. }
  203.  
  204. void ClearMsgPointers(void)
  205. {
  206.    struct MyConfBase *it;
  207.    struct MyConfBase *tt;
  208.    if(User.Slot_Number<=0) {
  209.        return;
  210.    }
  211.    it=(struct MyConfBase *)(ConfDBList->lh_Head);
  212.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  213.    {
  214.           it->CB.Bytes_Download=0L;
  215.           it->CB.Bytes_Upload=0L;
  216.           it->CB.Upload=0;
  217.           it->CB.Downloads=0;
  218.           it->CB.RatioType=0;
  219.           it->CB.Ratio=0;
  220.           it->CB.Messages_Posted=0;
  221.           it->CB.ConfYM=0;
  222.           it->CB.ConfRead=0;
  223.  
  224.       it=tt;
  225.    }
  226.  
  227. }
  228.  
  229. void AddMsgPointers(void)
  230. {
  231.    struct MyConfBase *it;
  232.    struct MyConfBase *tt;
  233.    if(User.Slot_Number<=0) { return;
  234.    }
  235.    it=(struct MyConfBase *)(ConfDBList->lh_Head);
  236. if(!GET_BIT(ACS_CONFERENCE_ACCOUNTING)) return;
  237.           User.Bytes_Download=    0L;
  238.           User.Bytes_Upload=      0L;
  239.           User.Uploads=           0;
  240.           User.Downloads=         0;
  241.           User.Messages_Posted=   0;
  242.  
  243.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  244.    {
  245.           User.Bytes_Download +=    it->CB.Bytes_Download;
  246.           User.Bytes_Upload +=      it->CB.Bytes_Upload;
  247.           User.Uploads +=           it->CB.Upload;
  248.           User.Downloads +=         it->CB.Downloads;
  249.           User.Messages_Posted +=   it->CB.Messages_Posted;
  250.  
  251.       it=tt;
  252.    }
  253.  
  254. }
  255.  
  256. int RelConf(int CN)
  257. {
  258.   register int i=0;
  259.   register int count=0;
  260.     while(i<CN)
  261.     {
  262.        if(GetAreaBit(i) || NotRelative) count++;
  263.        i++;
  264.     }
  265.   return(count);
  266. }
  267. int GetInverse(int CN)
  268. {
  269.   register int i=0;
  270.   register int j=0;
  271.   if(CN -1< 0) return(0);
  272.   if(NotRelative) return(CN);
  273.     while(i<CN)
  274.     {
  275.       if(j<Boards_Are_Active)
  276.       {
  277.           if(GetAreaBit(j)) i++;
  278.       } else { return(0); }
  279.       j++;
  280.     }
  281.   return(j);
  282.  
  283. }
  284.  
  285. void Save_ConfDB(int account,int conf,APTR address)
  286. {
  287.    BPTR bi;
  288.    register int i;
  289.    struct ConfBase *t;
  290.    struct MyConfBase *tt;
  291.    struct MyConfBase *it;
  292.    char temp[100];
  293.    char temp1[100];
  294.    t=address;
  295.  if(account==User.Slot_Number)
  296.    {
  297.       it=(struct MyConfBase *)(ConfDBList->lh_Head);
  298.    i=0;
  299.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  300.    {
  301.       if(conf-1==i)
  302.       {
  303.         CopyMem((APTR)t,(APTR)&(it->CB),sizeof(struct ConfBase));
  304.         return;
  305.       }
  306.       i++;
  307.       it=tt;
  308.    }
  309.      return;
  310.    }
  311.    GetConfName(temp,temp1,conf-1);
  312.    sprintf(temp,"%sConf.DB",temp1);
  313.    bi=Open(temp,MODE_OLDFILE);
  314.    if(bi==NULL)
  315.    {
  316.    CallersLog("\tError can't open >:"); CallersLog(temp); CallersLog("\n");
  317.   
  318.      return;
  319.    }
  320.  
  321.    if(Seek(bi,(ULONG)(account-1)*(ULONG)(sizeof(struct ConfBase)),OFFSET_BEGINNING)==-1)
  322.    {
  323.       CallersLog("\tError Saving MsgBase Pointer\n"); Close(bi); return;
  324.    }
  325.    Write(bi,(APTR)t,sizeof(struct ConfBase));
  326.    Close(bi);
  327.    GetConfName(temp,temp1,CN-1);
  328. }
  329. void Load_ConfDB(int account,int conf,APTR address)
  330. {
  331.    BPTR bi;
  332.    register int i;
  333.    struct ConfBase *t;
  334.    struct MyConfBase *it;
  335.    struct MyConfBase *tt;
  336.    char temp[100];
  337.    char temp1[100];
  338.    t=address;
  339.    if(account==User.Slot_Number)
  340.    {
  341.       it=(struct MyConfBase *)(ConfDBList->lh_Head);
  342.    i=0;
  343.    while(tt=(struct MyConfBase *)it->l.mln_Succ)
  344.    {
  345.       if(conf-1==i)
  346.       {
  347.         CopyMem((APTR)&(it->CB),(APTR)t,sizeof(struct ConfBase));
  348.         return;
  349.       }
  350.       i++;
  351.       it=tt;
  352.    }
  353.       return;
  354.    }
  355.    GetConfName(temp,temp1,conf-1);
  356.    sprintf(temp,"%sConf.DB",temp1);
  357.    bi=Open(temp,MODE_OLDFILE);
  358.    if(bi==NULL)
  359.    {
  360.    CallersLog("\tError can't open >:"); CallersLog(temp); CallersLog("\n");
  361.   
  362.      return;
  363.    }
  364.  
  365.    if(Seek(bi,(ULONG)(account-1)*(ULONG)(sizeof(struct ConfBase)),OFFSET_BEGINNING)==-1)
  366.    {
  367.       CallersLog("\tError Saving MsgBase Pointer\n"); Close(bi); return;
  368.    }
  369.    FRead(bi,(APTR)t,sizeof(struct ConfBase),1L);
  370.    Close(bi);
  371.    GetConfName(temp,temp1,CN-1);
  372. }
  373.